From 640c24310c9e32ba070eb2a13ac5850d95732621 Mon Sep 17 00:00:00 2001 From: "josht@us.ibm.com" Date: Sat, 13 Aug 2005 00:44:00 +0000 Subject: [PATCH] Make vm-top and the xenstat perl and python bindings conditional based on configuration variables from Config.mk, rather than disabling them if the needed headers are not found. --- Config.mk | 5 ++++ tools/xenstat/libxenstat/Makefile | 42 ++++++++++++++++++++----------- tools/xenstat/vm-top/Makefile | 20 ++++++--------- 3 files changed, 41 insertions(+), 26 deletions(-) diff --git a/Config.mk b/Config.mk index 2eb5eae86f..7991af7b2c 100644 --- a/Config.mk +++ b/Config.mk @@ -35,3 +35,8 @@ CFLAGS += $(foreach i, $(EXTRA_INCLUDES), -I$(i)) # Choose the best mirror to download linux kernel KERNEL_REPO = http://www.kernel.org + +# Optional components +XENSTAT_PERL_BINDINGS ?= n +XENSTAT_PYTHON_BINDINGS ?= y +XENSTAT_VM_TOP ?= y diff --git a/tools/xenstat/libxenstat/Makefile b/tools/xenstat/libxenstat/Makefile index 98b16c3e7f..d1dee3bd86 100644 --- a/tools/xenstat/libxenstat/Makefile +++ b/tools/xenstat/libxenstat/Makefile @@ -42,8 +42,6 @@ CFLAGS+=-I$(XEN_ROOT)/xen/include/public CFLAGS+=-I$(LINUX_ROOT)/include/asm-xen/linux-public/ LDFLAGS+=-Lsrc -# Note that the bindings are not built by default, because they require a -# number of external dependencies. all: $(LIB) $(LINKS) $(LIB): $(OBJECTS) @@ -81,12 +79,16 @@ BINDINGS=$(PYLIB) $(PYMOD) $(PERLLIB) $(PERLMOD) BINDINGSRC=$(PYSRC) $(PERLSRC) # The all-bindings target builds all the language bindings -all-bindings: $(BINDINGS) +all-bindings: perl-bindings python-bindings + +# The install-bindings target installs all the language bindings +install-bindings: install-perl-bindings install-python-bindings $(BINDINGS): $(LIB) $(LINKS) src/xenstat.h SWIG_FLAGS=-module xenstat -Isrc +# Python bindings PYTHON_VERSION=2.3 PYTHON_FLAGS=-I/usr/include/python$(PYTHON_VERSION) -lpython$(PYTHON_VERSION) $(PYSRC) $(PYMOD): bindings/swig/xenstat.i @@ -95,6 +97,19 @@ $(PYSRC) $(PYMOD): bindings/swig/xenstat.i $(PYLIB): $(PYSRC) $(CC) $(CFLAGS) $(LDFLAGS) $(PYTHON_FLAGS) -shared -lxenstat -o $@ $< +python-bindings: $(PYLIB) $(PYMOD) + +pythonlibdir=$(prefix)/lib/python$(PYTHON_VERSION)/site-packages +install-python-bindings: $(PYLIB) $(PYMOD) + $(INSTALL_PROG) $(PYLIB) $(DESTDIR)$(pythonlibdir)/_xenstat.so + $(INSTALL_PROG) $(PYMOD) $(DESTDIR)$(pythonlibdir)/xenstat.py + +ifeq ($(XENSTAT_PYTHON_BINDINGS),y) +all: python-bindings +install: install-python-bindings +endif + +# Perl bindings PERL_FLAGS=`perl -MConfig -e 'print "$$Config{ccflags} -I$$Config{archlib}/CORE";'` $(PERLSRC) $(PERLMOD): bindings/swig/xenstat.i swig -perl $(SWIG_FLAGS) -outdir $(@D) -o $(PERLSRC) $< @@ -102,19 +117,18 @@ $(PERLSRC) $(PERLMOD): bindings/swig/xenstat.i $(PERLLIB): $(PERLSRC) $(CC) $(CFLAGS) $(LDFLAGS) $(PERL_FLAGS) -shared -lxenstat -o $@ $< -# The install-bindings target installs all the language bindings -install-bindings: install-perl-bindings install-python-bindings +perl-bindings: $(PERLLIB) $(PERLMOD) -pythonlibdir=$(prefix)/lib/python$(PYTHON_VERSION)/site-packages -install-python-bindings: $(PYLIB) $(PYMOD) - $(INSTALL_PROG) $(PYLIB) $(pythonlibdir)/_xenstat.so - $(INSTALL_PROG) $(PYMOD) $(pythonlibdir)/xenstat.py - -perllibdir=$(prefix)/lib/site_perl -perlmoddir=$(prefix)/lib/site_perl +perllibdir=$(prefix)/lib/perl5 +perlmoddir=$(prefix)/share/perl5 install-perl-bindings: $(PERLLIB) $(PERLMOD) - $(INSTALL_PROG) $(PERLLIB) $(perllibdir)/xenstat.so - $(INSTALL_PROG) $(PERLMOD) $(perlmoddir)/xenstat.pm + $(INSTALL_PROG) $(PERLLIB) $(DESTDIR)$(perllibdir)/xenstat.so + $(INSTALL_PROG) $(PERLMOD) $(DESTDIR)$(perlmoddir)/xenstat.pm + +ifeq ($(XENSTAT_PERL_BINDINGS),y) +all: perl-bindings +install: install-perl-bindings +endif clean: rm -f $(LIB) $(OBJECTS) $(LINKS) $(BINDINGS) $(BINDINGSRC) diff --git a/tools/xenstat/vm-top/Makefile b/tools/xenstat/vm-top/Makefile index c1655cabf3..19e46ad896 100644 --- a/tools/xenstat/vm-top/Makefile +++ b/tools/xenstat/vm-top/Makefile @@ -10,16 +10,13 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -ifneq (,$(shell [ -e /usr/include/curses.h ] || echo no)) -all vm-top: - @echo "***********************************************************" - @echo "WARNING: Install ncurses to build vm-top." - @echo "***********************************************************" -else - XEN_ROOT=../../.. include $(XEN_ROOT)/tools/Rules.mk +ifneq ($(XENSTAT_VM_TOP),y) +all install vm-top: +else + INSTALL = install INSTALL_PROG = $(INSTALL) -m0755 -D INSTALL_DATA = $(INSTALL) -m0644 -D @@ -36,12 +33,11 @@ all: vm-top vm-top: vm-top.o -endif - install: vm-top vm-top.1 - [ -f vm-top ] && $(INSTALL_PROG) vm-top $(DESTDIR)$(sbindir)/vm-top - [ -f vm-top.1 ] && \ - $(INSTALL_DATA) vm-top.1 $(DESTDIR)$(man1dir)/vm-top.1 + $(INSTALL_PROG) vm-top $(DESTDIR)$(sbindir)/vm-top + $(INSTALL_DATA) vm-top.1 $(DESTDIR)$(man1dir)/vm-top.1 + +endif clean: rm -f vm-top vm-top.o -- 2.30.2